package org.beetl.support;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import javax.sql.DataSource;

import org.beetl.sql.core.ConnectionSource;

public class DataSourceConnectionSource implements ConnectionSource {

 private DataSource master;

 private DataSource slave;

 /**
  * The Constructor.
  *
  * @param master
  *         the master
  */
 public DataSourceConnectionSource(DataSource master) {
  this(master, master);
 }

 public DataSourceConnectionSource(DataSource master, DataSource slave) {
  super();
  this.master = master;
  this.slave = slave;
 }

 public Connection getMaster() throws SQLException {
  return this.master.getConnection();
 }

 public Connection getSlave() throws SQLException {
  return this.slave.getConnection();
 }

 public Connection getConn(String sqlId, boolean isUpdate, String sql, List<?> paras) throws SQLException {
  return this.getMaster();
 }

 public void forceBegin(boolean isMaster) {

 }

 public void forceEnd() {

 }

 public boolean isTransaction() {
  return false;
 }

}
